/*
 * CS_SOCIAL_FRIEND_ALL_BUF_TIME.cpp
 *
 *  Created on: 2013. 7. 24.
 *      Author: the2
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../Proxy.h"
#include "../../../../protocol/iFriends.h"

#include "../../NLogic/Buff.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_SOCIAL_FRIEND_ALL_BUF_TIME(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	NLogic::Buff * pBuff = pUser->GetBuff();
	if (NULL == pBuff)
		return;
	NLogic::Buff::Data * pData = pBuff->GetData(NLogic::Buff::BuffType::FRIEND);
	if (NULL == pData)
		return;

	time_t curtime = time(NULL);
	if (pData->_regdate - curtime > 0)
	{
		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		* pAck << static_cast<int16_t>(ACK_OK) << static_cast<uint32_t>(pData->_regdate - curtime);
		pAck->MakePacket(CMD_SC_SOCIAL_FRIEND_ALL_BUF_TIME);
		pUser->Send(pAck);
		return;
	}

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	* pAck << static_cast<int16_t>(ACK_OK) << static_cast<uint32_t>(0);
	pAck->MakePacket(CMD_SC_SOCIAL_FRIEND_ALL_BUF_TIME);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/

